import React, { PureComponent } from 'react';
import { Flex, Icon } from 'antd-mobile';


import { coupon_Item } from './CouponItem.less';
import {routerRedux} from "dva/router";

const goodsTypes = {
  0: '全部商品',
  1: '指定商品分类',
  2: '指定商品类型',
  3: '指定品牌',
  4: '指定商品',
};

class CouponItem extends PureComponent {
  constructor(props) {
    super(props);
  }


  render() {
    const { Item, dispatch, storeId } = this.props;
    const { id, isGet, couponSource="", description="", shopActivityEntity={} } = Item;

    return (
      <div  className={coupon_Item}>

         <div className="bg">
           <Flex justify="center" className="body">
             <div className="left">
               {/*<div className="type">全场通用</div>*/}
               <div className="store_name">{shopActivityEntity.storeName}</div>
               <Flex className="price">
                   <div style={{ minWidth:"1rem" , height:"0.8rem", lineHeight:'0.8rem', textAlign:"right"}}>{couponSource}</div>
                   <div style={{ marginLeft:'0.1rem', fontSize:"0.36rem" }}>元</div>
               </Flex>
             </div>
             <div className="center">
               <div style={{ marginTop:'0.5rem', fontSize:"0.28rem" }}>{description}</div>
               <div style={{ marginTop:'0.15rem', fontSize:"0.20rem" }}>{shopActivityEntity.startTimeStr}-{shopActivityEntity.endTimeStr}</div>
             </div>
             <div className="right">
                 {
                     isGet==1 ?
                         <Flex justify="center" align="center" className="state">
                           <Flex justify="center" align="end"  className="inner_state">
                             <div style={{ margin:"0rem 0rem 0.3rem 0rem" }}>已领取</div>
                           </Flex>
                         </Flex>
                         : ""
                 }
                 {
                     isGet==0 ? <div
                                   onClick={()=>{
                                       dispatch({ type:"cart/receiveCouponEFF", obj:{ id, storeId } })

                                   }}
                                   className="btn"
                                   >
                                   点击领取
                                 </div> :
                                 ""
                 }

             </div>
           </Flex>

           <img src={require("../../assets/img/couponYes.png")} />
         </div>
          <div className="use_preson">
              <span>会员限制：{Item.shopActivityEntity.memberLevel}；</span>
              <span>商品限制：{Item.shopActivityEntity.goodsType == 0 ? "全部商品" : Item.shopActivityEntity.goodsType == 1 ? "指定商品分类" :Item.shopActivityEntity.goodsType == 2 ? "指定商品类型": Item.shopActivityEntity.goodsType==3 ? "指定品牌" : '指定商品'}</span>
          </div>
      </div>
      );
  }
}

export default CouponItem;

/*
 * 以前测试的，未使用
 * */